<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-iLine-add">
			<input name="deptId" type="hidden" id="treeId"/>
			<input name="upLineId" type="hidden" id="line_id"/>
			<input name="byqId" type="hidden" id="byq_id"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">线路名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">运行编号：</label>
				<div class="col-sm-8">
					<input id="runCode" name="runCode" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">线路类型：</label>
				<div class="col-sm-8">
					<!--<input id="lineType" name="lineType" class="form-control" type="text">-->
					<!--<select id="lineType" class="form-control" name="lineType"-->
							<!--th:with="type=${@dict.getType('line_type')}">-->
						<!--<option th:text="请选择" value=""></option>-->
						<!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
					<!--</select>-->
					<select id="lineType" class="form-control" name="lineType">
						<option value="">请选择</option>
						<option value="架空线">架空线</option>
						<option value="电缆线">电缆线</option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">电压等级：</label>
				<div class="col-sm-8">
					<!--<input id="voltage" name="voltage" class="form-control" type="text">-->
					<!--<select id="voltage" class="form-control" name="voltage"-->
							<!--th:with="type=${@dict.getType('voltage_grade')}">-->
						<!--<option th:text="请选择" value=""></option>-->
						<!--<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
					<!--</select>-->
					<select id="voltage" class="form-control" name="voltage">
						<option value="">请选择</option>
						<option value="10kv">10kv</option>
						<option value="400v">400v</option>
						<option value="220v">220v</option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">线路总长度：</label>
				<div class="col-sm-8">
					<input id="totalSpan" name="totalSpan" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">架空线路总长度：</label>
				<div class="col-sm-8">
					<input id="overSpan" name="overSpan" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">电缆总长度：</label>
				<div class="col-sm-8">
					<input id="cableSpan" name="cableSpan" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">变压器：</label>
				<div class="col-sm-8">
					<input id="byq_name" name="byqName" class="form-control" type="text" onclick="chooseByq()">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">上级线路：</label>
				<div class="col-sm-8">
					<input id="line_name" name="upLineName" class="form-control" type="text" onclick="chooseUpLine()">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">资产单位：</label>
				<div class="col-sm-8">
					<input id="treeName" name="unit" class="form-control" type="text" onclick="selectDeptTree()">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">运维班组：</label>
				<div class="col-sm-8">
					<input id="runTeam" name="runTeam" class="form-control" type="text">
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">创建人：</label>
				<div class="col-sm-8">
					<input id="addUser" name="addUser" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">创建日期：</label>
				<div class="col-sm-8">
					<input id="addDate" name="addDate" class="form-control" type="date">
				</div>
			</div>-->
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">最近更新人：</label>
				<div class="col-sm-8">
					<input id="updateUser" name="updateUser" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">最近更新日期：</label>
				<div class="col-sm-8">
					<input id="updateDate" name="updateDate" class="form-control" type="date">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">数据状态：</label>
				<div class="col-sm-8">
					<input id="datastate" name="datastate" class="form-control" type="text">
				</div>
			</div>-->
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "assets/iLine"
		$("#form-iLine-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});

		/**
		 * 	提交保存
		 */
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-iLine-add').serialize());
	            console.log("变压器id=="+$("#byq_id").val())
	            console.log("变压器name=="+$("#byq_name").val())
	        }
	    }


        /**
         * 	选择变压器
         */
        function chooseByq(){
            //	打开方式一
            layer.open({
                type: 2,
                title: '变压器选择',
                area: ['950px', '340px'],
                fixed: false, //不固定
                maxmin: true,
                content: ctx+"assets/bByq/chooseByq",
                btn: ['确定', '关闭'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function (index,layero) {
                    var body = layer.getChildFrame('body', index);//得到iframe页的body内容
                    $("#byq_id").val(body.find('#byq_id').val());
                    $("#byq_name").val(body.find('#byq_name').val());
                    layer.close(index);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }


        /**
		 * 	选择上级线路
         */
        function chooseUpLine(){
            //	打开方式一
            layer.open({
                type: 2,
                title: '上级线路选择',
                area: ['950px', '340px'],
                fixed: false, //不固定
                maxmin: true,
//                content: ctx+"assets/b10kvLineInfo/choose10kvLine",
                content: ctx+"assets/iLine/chooseLine",
                btn: ['确定', '关闭'],
                // 弹层外区域关闭
                shadeClose: true,
                yes: function (index,layero) {
                    var body = layer.getChildFrame('body', index);//得到iframe页的body内容
                    $("#line_id").val(body.find('#line_id').val());
                    $("#line_name").val(body.find('#line_name').val());
                    layer.close(index);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }




        /**
		 * 	资产单位Tree
         */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
//            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: ctx + "system/dept/selectDeptTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
		/** 资产单位赋值*/
        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
//                console.log("body3333=="+body.html())
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }


	</script>
</body>
</html>
